﻿using System.Collections.Generic;
using NPoco;

namespace BestEasyCMS.Service.Mappers
{
    /// <summary>
    /// 分页的扩展转换方法
    /// </summary>
    public static class PageExtensionMethods
    {
        public static Page<TView> ToPageView<TView, TEntity>(this Page<TEntity> pageEntity)
        {
            var pageView = new Page<TView>
            {
                CurrentPage = pageEntity.CurrentPage,
                TotalItems = pageEntity.TotalItems,
                TotalPages = pageEntity.TotalPages,
                ItemsPerPage = pageEntity.ItemsPerPage,
                Items = (List<TView>)Convert<TView, TEntity>.ToViews(pageEntity.Items)
            };
            return pageView;
        }
    }
}
